/*
*   配送管理
* */
import React,{Component} from 'react';
import Util from '../common/util'
import OrderList from './distribution/orderList';//配送订单列表
import {
    View,
    Text,
    Image,
    TouchableOpacity,
    Animated,
    StyleSheet
} from 'react-native';
import Toast from '../common/ToastUtil';
export default class deliveryManager extends Component{
    // 构造
      constructor(props) {
        super(props);
        // 初始状态
        this.state = {};
      }


    toOrderList(status){
        this.props.navigator.push({
            component:OrderList,
            passProps:{
                user_id:this.props.user_id,
                shop_id:this.props.shop_id,
                identity_id:this.props.identity_id,
                role_id:this.props.role_id,
                order_type:0,
                delivery_status:status
            }
        })
    }

      render(){
          let deliveryOrder = this.props.data
          return(
              <View style={{marginTop:10,backgroundColor:"#fff"}}>
                  <View style={styles.header_view}>
                      <View style={styles.rows_view}>
                          <Image
                              source={require('../imgs/center_icon19.png')}
                              style={{width:25,height:25,marginRight:5}}
                              resizeMode={'cover'}
                          />
                          <Text style={{fontSize:14,color:"#333"}}>{this.props.role_id==8?'配送订单管理':'配货订单管理'}</Text>
                      </View>
                      <TouchableOpacity onPress={()=>this.toOrderList(0)} style={styles.rows_view}>
                          <Text style={{fontSize:12,color:"#696969"}}>查看全部订单</Text>
                          <Image
                              source={require('../imgs/right_arrow.png')}
                              style={{width:15,height:15,}}
                              resizeMode={'cover'}
                          />
                      </TouchableOpacity>
                  </View>
                  <View style={styles.four_view}>
                      <TouchableOpacity onPress={()=>this.toOrderList(5)} style={styles.manager_item}>
                          <Image
                              source={require('../imgs/payment1.png')}
                              style={{width:25,height:25,marginBottom:5}}
                              resizeMode={'cover'}
                          />
                          <Text style={{fontSize:14,color:"#333"}}>待配货</Text>
                          {
                              deliveryOrder.wait_distribution>0?
                                  <View style={styles.num_view}>
                                      <Text style={{fontSize:12,color:"#fff",backgroundColor:'transparent'}}>{deliveryOrder.wait_distribution}</Text>
                                  </View>
                                  :
                                  null
                          }
                      </TouchableOpacity>
                      <TouchableOpacity onPress={()=>this.toOrderList(1)} style={styles.manager_item}>
                          <Image
                              source={require('../imgs/payment2.png')}
                              style={{width:25,height:25,marginBottom:5}}
                              resizeMode={'cover'}
                          />
                          <Text style={{fontSize:14,color:"#333"}}>待配送</Text>
                          {
                              deliveryOrder.wait_delivery>0?
                                  <View style={styles.num_view}>
                                      <Text style={{fontSize:12,color:"#fff",backgroundColor:'transparent'}}>{deliveryOrder.wait_delivery}</Text>
                                  </View>
                                  :
                                  null
                          }
                      </TouchableOpacity>
                      <TouchableOpacity onPress={()=>this.toOrderList(3)} style={styles.manager_item}>
                          <Image
                              source={require('../imgs/payment3.png')}
                              style={{width:25,height:25,marginBottom:5}}
                              resizeMode={'cover'}
                          />
                          <Text style={{fontSize:14,color:"#333"}}>配送中</Text>
                          {
                              deliveryOrder.deliverying>0?
                                  <View style={styles.num_view}>
                                      <Text style={{fontSize:12,color:"#fff",backgroundColor:'transparent'}}>{deliveryOrder.deliverying}</Text>
                                  </View>
                                  :
                                  null
                          }
                      </TouchableOpacity>
                      <TouchableOpacity onPress={()=>this.toOrderList(4)} style={styles.manager_item}>
                          <Image
                              source={require('../imgs/payment4.png')}
                              style={{width:25,height:25,marginBottom:5}}
                              resizeMode={'cover'}
                          />
                          <Text style={{fontSize:14,color:"#333"}}>已完成</Text>
                          {
                              deliveryOrder.success>0?
                                  <View style={styles.num_view}>
                                      <Text style={{fontSize:12,color:"#fff",backgroundColor:'transparent'}}>{deliveryOrder.success}</Text>
                                  </View>
                                  :
                                  null
                          }
                      </TouchableOpacity>
                  </View>
              </View>
          )
      }
}
var styles = StyleSheet.create({
    header_view:{
        height:40,
        paddingHorizontal:10,
        borderBottomColor:"#e0e0e0",
        borderBottomWidth:1,
        flexDirection:'row',
        alignItems:'center',
        justifyContent:'space-between'
    },
    four_view:{
        flexDirection:'row',
        alignItems:'center',
        flexWrap:'wrap'
    },
    manager_item:{
        alignItems:'center',
        justifyContent:'center',
        width:Util.size.width/4,
        paddingVertical:10
    },
    num_view:{
        width:18,
        height:18,
        alignItems:'center',
        justifyContent:'center',
        backgroundColor:"#f00",
        borderRadius:9,
        position:'absolute',
        top:5,
        right:Util.size.width/8-18
    },
    rows_view:{
        flexDirection:'row',
        alignItems:'center'
    }
})